********************************************************************************
**JOP Replication - "Resisting the Blood Tax" - Cantons Data - Appendix*********
**Lindsey Pruett****************************************************************
**September 2023****************************************************************
**Stata 17.0********************************************************************
********************************************************************************

clear
use "C:\Users\ldpru\OneDrive\Desktop\Replication_JOP\JOP_Pruett_cantons.dta"

*Tables in Appendix*************************************************************

*Table 11: Descriptive Statistics for Senegal Canton

global VARS Border_20 rail_5 rail_10 rail_15 rail_20 abs_pop Absents Eligible KM_Station Soil_jed H2o W_Town pop_density pop_quartile

eststo sum: estpost summarize $VARS

esttab sum sum sum sum sum using can_sum.tex, replace ///
cell(count(pattern(1 0 0 0 0) fmt(0)) & mean(pattern(0 1 0 0 0) fmt(2)) & sd(pattern(0 0 1 0 0) fmt(2)) & min(pattern(0 0 0 1 0) fmt(0)) & max(pattern(0 0 0 0 1) fmt(2))) mtitle("n" "Mean" "SD" "Min" "Max")


*alternately look at for basic summary statistics
*tabstat Border_20 rail_5 rail_10 rail_15 rail_20 abs_pop Absents Eligible KM_Station Soil_jed H2o W_Town pop_density pop_quartile, stat(n mean sd min max)

*Table 12: Balance Among Rail/Non Rail at 5km
ttest Border_20, by(rail_5)
ttest W_Town, by(rail_5)
ttest Soil_jed, by(rail_5)
ttest H2o, by(rail_5)
ttest pop_density, by(rail_5)

*Table 13: ATE for Draft Evasion (Propensity Score Matching)

preserve 
teffects psmatch (abs_pop) (rail_5 Border_20 Soil_jed H2o pop_density W_Town Year), vce(iid)
teffects overlap
outreg2 using pmatch1.tex, replace tex(fragment pretty)

teffects psmatch (abs_pop) (rail_10 Border_20 Soil_jed H2o pop_density W_Town Year), vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)

teffects psmatch (abs_pop) (rail_15 Border_20 Soil_jed H2o pop_density W_Town Year), vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)


teffects psmatch (abs_pop) (rail_20 Border_20 Soil_jed H2o pop_density W_Town Year), vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)

teffects psmatch (abs_pop) (rail_5 Border_20 Soil_jed H2o pop_density W_Town Year), nneighbor(2) vce(iid)
teffects overlap
outreg2 using pmatch1.tex, append tex(fragment pretty)

teffects psmatch (abs_pop) (rail_10 Border_20 Soil_jed H2o pop_density W_Town Year), nneighbor(2) vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)

teffects psmatch (abs_pop) (rail_15 Border_20 Soil_jed H2o pop_density W_Town Year), nneighbor(2) vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)


teffects psmatch (abs_pop) (rail_20 Border_20 Soil_jed H2o pop_density W_Town Year), nneighbor(2) vce(iid)
outreg2 using pmatch1.tex, append tex(fragment pretty)

restore


*Table 14: Coarsened Exact Matching - Main Paper Results

cem Border_20 pop_quartile Year, tr(rail_5)
reg abs_pop rail_5 [iweight=cem_weights]
outreg2 using cem1.tex, replace tex(fragment pretty)

reg abs_pop rail_5 Border_20 Soil_jed H2o pop_quartile W_Town [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)

cem Border_20 pop_quartile Year, tr(rail_10)
reg abs_pop rail_10 [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)

reg abs_pop rail_10 Border_20 Soil_jed H2o pop_quartile W_Town [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)

cem Border_20 pop_quartile Year, tr(rail_15)
reg abs_pop rail_15 [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)

reg abs_pop rail_15 Border_20 Soil_jed H2o pop_quartile W_Town [iweight=cem_weights]
estimates store F


cem Border_20 pop_quartile, tr(rail_20)
reg abs_pop rail_20 [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)

reg abs_pop rail_20 Border_20 Soil_jed H2o pop_quartile W_Town [iweight=cem_weights]
outreg2 using cem1.tex, append tex(fragment pretty)


*Table 15: Coarsened Exact Matching without Kidira 
preserve

drop if Canton=="Kidiri"
drop if Canton=="Kidira"

cem Border_20 pop_quartile, tr(rail_5)
reg abs_pop rail_5 [iweight=cem_weights]
outreg2 using cem.tex, replace

cem Border_20 pop_quartile, tr(rail_10)
reg abs_pop rail_10 [iweight=cem_weights]
outreg2 using cem.tex, append

cem Border_20 pop_quartile, tr(rail_15)
reg abs_pop rail_15 [iweight=cem_weights]
outreg2 using cem.tex, append

cem Border_20 pop_quartile, tr(rail_20)
reg abs_pop rail_20 [iweight=cem_weights]
outreg2 using cem.tex, append

restore

*Table 18: Mann Whitney Test
ranksum abs_pop, by(border_20_40)

*Additional Statistics and Checks in the Appendix*************************************************************

*Population Density Around Louga-Linguere Line
list Canton Eligible Year if Canton=="Yang Yang" || Canton=="Yang Yang Guebol"
list Canton Eligible Year if Canton=="Djoloff Oriental"
list Canton Eligible Year if Canton=="Passe Bakhale"
list Canton Eligible Year if Canton=="Dienguel" || Canton=="Ndienguel"
list Canton Eligible Year if Canton=="Lathie"
list Canton Eligible Year if Canton=="Djevol" || Canton=="Djevol Thiatde"





